/**
 * Creat by TanLei
 * Description:
 * User:86183
 * Date:2022-05-12
 * Time:11:59
 */
class SingletonDataSource {
    private static SingletonDataSource instance = new SingletonDataSource();

    private SingletonDataSource() {

    }

    public static SingletonDataSource getInstance() {
        return instance;
    }
}

class SingletonDataSourse2 {
    private static volatile SingletonDataSourse2 instance = null;

    private SingletonDataSourse2() {

    }

    public static SingletonDataSourse2 getInstance() {
        if (instance == null) {
            synchronized (SingletonDataSourse2.class) {
                if (instance == null) {
                    instance = new SingletonDataSourse2();
                }
            }
        }
        return instance;
    }
}

public class Demo20 {
    public static void main(String[] args) {
        SingletonDataSource dataSource = SingletonDataSource.getInstance();
    }
}
